/*
 * 10.5_1.cpp 1458_poj
 *
 *  Created on: 2012-5-16
 *      Author: jawinton
 */


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 201

char s1[MAX], s2[MAX];
int common[MAX][MAX];

int main (void) {
	while (scanf("%s %s", s1, s2) > 0) {
		int len1 = strlen(s1), len2 = strlen(s2);
		for (int i=0; i<=len1; i++) {
			common[i][0] = 0;
		}
		for (int j=0; j<=len2; j++) {
			common[0][j] = 0;
		}
		for (int i=1; i<=len1; i++) {
			for (int j=1; j<=len2; j++) {
				if (s1[i-1] == s2[j-1]) {
					common[i][j] = common[i-1][j-1]+1;
				} else {
					common[i][j] = max(common[i-1][j], common[i][j-1]);
				}
			}
		}
		printf("%d\n", common[len1][len2]);
	}
	return 0;
}
